/*
 * Copyright (C) 2009 Kristopher T Babic
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, see <http://www.gnu.org/licenses>.
 */

package edu.idp.client.event;

import java.util.EventObject;

/**
 *
 * @author Kristopher T Babic
 */
public class ServerStatusEvent extends EventObject {

    public static final int CONNECTING = 0;
    public static final int CONNECTED = 1;
    public static final int DISCONNECTED = 2;
    public static final int SERVER_ERROR = 3;
    public static final int SERVER_LOST = 4;
    public static final int SENDING_DATA = 5;
    public static final int RECEIVING_DATA = 6;
    public static final int UNKNOWN = 7;

    // 	private boolean status;
    private int status;
    private java.lang.String statusString = null;

    private final java.lang.String TRUE = "Server connection is ok";
    private final java.lang.String FALSE = "Server connection is disrupted";

    public ServerStatusEvent(Object o) {
        this(o, UNKNOWN);
    }

    public ServerStatusEvent(Object o, int status) {
        super(o);
        this.status = status;
/*
		if (status)
			statusString = TRUE;
		else
			statusString = FALSE;
*/
    }

    /*
       public void setStatus(boolean status) { this.status = status; }
       public boolean getStatus() { return status; }
    */
    public void setStatus(int status) {
        this.status = status;
    }

    public int getStatus() {
        return status;
    }

    public void setStatusString(java.lang.String s) {
        statusString = s;
    }

    public java.lang.String getStatusString() {
        return statusString;
    }

    public String toString() {

        switch (getStatus()) {
            case CONNECTING:
                return "Establishing a connection to the server.";
            case CONNECTED:
                return "Connected to the server.";
            case DISCONNECTED:
                return "Connection Disrupted.";
            case SERVER_ERROR:
                return "Server Error.";
            case SERVER_LOST:
                return "Connection to server has been lost.";
            case SENDING_DATA:
                return "Sending data to server.";
            case RECEIVING_DATA:
                return "Receiving data to server.";
            case UNKNOWN:
                return "Status is unknown.";
        }
        return "";
        //		return getStatusString();
    }

/*
  public String getValue () { return value; }
  public void   setValue (String value) { this.value = value; }

  public int  getTerminatingCharacter () { return terminatingCharacter; }
  public void setTerminatingCharacter (int termChar) { terminatingCharacter = termChar; }

  public String getPreviousValue () { return previousValue; }
  public void   setPreviousValue (String value) { this.previousValue = value; }

  public String toString () {
    return new String (value);
  }
*/
}
